SELECT max(t.id) FROM C1_SITE T WHERE ( NOW() BETWEEN IFNULL(T.BEGIN_DATE, NOW()) AND IFNULL(T.END_DATE, NOW()) ) AND t.code = :code